<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>mymsgro</title>
	<link rel="stylesheet" type="text/css" href="css/main.css" />
	<link rel="stylesheet" type="text/css" href="css/meniu.css" />
	<link rel="stylesheet" type="text/css" href="css/style.css" />
</h:head>
<h:body>
	<ui:include src="header.xhtml" />

	<h:panelGroup layout="block" id="content">

		<ui:include src="leftMenu.xhtml" />

		<h:panelGroup layout="block" id="contenRight">

			<h:panelGroup layout="block" id="header" style="margin-top: 20px;">
				<ul>
					<li id="selected"><a>My Books</a></li>
				</ul>
			</h:panelGroup>

			<h:panelGroup layout="block" id="contentTab">

				<h:outputText value="#{bookTableData.noRights}" />
				<h:form id="bookTable">
						Search:
						<h:inputText id="inputTextSearch"
						value="#{bookTableData.textToSearch}" />
					<h:commandButton value="Search Book"
						action="#{bookTableData.searchUsersBooks}" />
					<h:commandButton value="Suggest book" action="bookSugestion.xhtml" />
					<h:commandButton style="width: 17px; margin-right: 10px;"
						image="resources/img/view-refresh.png"
						action="#{bookTableData.refreshBooks}" />

					<br />
					<h:outputText value="#{bookTableData.succesMessage}"></h:outputText>
					<br />
					<p:dataTable id="dt" value="#{bookTableData.booksUser}" var="book"
						paginator="true" rows="#{bookTableData.nrRows}"
						paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
						rowsPerPageTemplate="5,10,15">
						<p:column>
							<f:facet name="header">
								<h:commandLink action="#{bookTableData.booksUser.sortByName}">
									<h:outputText value="Book title" />
								</h:commandLink>
							</f:facet>
							<h:outputText id="bookName" value="#{book.book.name}" />
						</p:column>
						<p:column>
							<f:facet name="header">
								<h:commandLink action="#{bookTableData.booksUser.sortByAuthor}">
									<h:outputText value="Author" />
								</h:commandLink>
							</f:facet>
							<h:outputText id="author" value="#{book.book.author}" />
						</p:column>

						<p:column>
							<f:facet name="header">
								<h:outputText value="Domain" />
							</f:facet>
							<h:outputText id="domain" value="#{book.domain.name}" />
						</p:column>

						<p:column>
							<f:facet name="header">
								<h:outputText value="Year" />
							</f:facet>
							<h:outputText id="year" value="#{book.book.year}" />
						</p:column>

						<p:column>
							<f:facet name="header">
								<h:outputText value="Status" />
							</f:facet>
							<h:outputText id="status" value="#{book.book.status}" />
						</p:column>

						<p:column>
							<f:facet name="header">
								<h:outputText value="Rating"></h:outputText>

							</f:facet>
							<p:rating disabled="#{book.ratingUser == true}"
								value="#{book.rating}" cancel="false">
								<p:ajax event="rate" update="@form"
									listener="#{bookTableData.newRating}" />
							</p:rating>
						</p:column>

						<p:column>
							<f:facet name="header">
								<h:outputText value="Reserve Book" />
							</f:facet>
							<h:commandButton value="Reserve" id="wantBookButton"
								actionListener="#{bookTableData.informNeedBook}"
								disabled="#{book.availableToBorrow}">
								<f:attribute name="currentBookBean" value="#{book}" />
							</h:commandButton>
						</p:column>

						<p:column>
							<f:facet name="header">
								<h:outputText value="Waiting List" />
							</f:facet>
							<h:commandButton value="Waiting list"
								id="queueBookButton"
								actionListener="#{bookTableData.putUserOnWaitingList}"
								disabled="#{book.availableToQueue}">
								<f:attribute name="currentBookBean" value="#{book}" />
							</h:commandButton>
						</p:column>

						<p:column>
							<h:commandButton value="Write your Review"
								image="/resources/img/user_review.png"
								action="#{bookTableData.bookReviews}">
							</h:commandButton>
						</p:column>
						<p:column>
							<h:commandButton value="See Critic's Review"
								rendered="#{bookTableData.containsCristicsReview(book.book.id)}"
								actionListener="#{bookTableData.getCriticsReview}"
								image="/resources/img/critic-review.png">
								<f:attribute name="currentBook" value="#{book}" />
							</h:commandButton>
						</p:column>
					</p:dataTable>
					<h:outputText value="#{bookTableData.succesMessage}"></h:outputText>
				</h:form>
			</h:panelGroup>
		</h:panelGroup>
	</h:panelGroup>
</h:body>
</html>
